<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>ECMAsctipt入门介绍</title>
</head>
<body>
    <!-- 用途
        1.rest(可变)参数
        *用来取代arguments 但比 arguments灵活，只能是最后部分形参的参数
        function fun(...values){
            console.log(arguments);
            arguments.forEach(function(item,index){
                console.log(item,index);
            })
            console.log(values);
            values.forEach(function(item,index){
                console.log(item,index)
            })
        }
        fun(1,2,3);
        2.扩展运算符
        let arr1 = [1,3,5]
        let arr2 = [2,...arr1,6];
        arr2.push(...arr1)
    -->
    
    <script>
        function foo(a,b){
            console.log(arguments)
            //arguments.callee() //执行函数本身
            // arguments.forEach(function(item,index){
            //     console.log(item,index)
            // })//arguments是伪数组，不具有数组的一般方法；
        }
        foo(3,6)
        function fun(...values){
            console.log(values)
            console.log(arguments);
            arguments.forEach(function(item,index){
                console.log(item,index);
            })
            console.log(values);
            values.forEach(function(item,index){
                console.log(item,index)
            })
        }
        //fun(1,2,3);
        let arr = [4,5,6]
        console.log(...arr)
        fun(...arr)
    </script>
</body>
</html>